package com.yizhu.zczy.article.controller;

import java.util.Arrays;
import java.util.Map;


import com.yizhu.zczy.common.utils.PageUtils;
import com.yizhu.zczy.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yizhu.zczy.article.entity.NavEntity;
import com.yizhu.zczy.article.service.NavService;




/**
 * 单页管理
 *
 * @author guoyz
 * @email guoyz@mail.com
 * @date 2021-06-24 17:26:57
 */
@RestController
@RequestMapping("article/nav")
public class NavController {
    @Autowired
    private NavService navService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("article:nav:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = navService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{navId}")
    //@RequiresPermissions("article:nav:info")
    public R info(@PathVariable("navId") Integer navId){
		NavEntity nav = navService.getById(navId);

        return R.ok().put("nav", nav);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("article:nav:save")
    public R save(@RequestBody NavEntity nav){
		navService.save(nav);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("article:nav:update")
    public R update(@RequestBody NavEntity nav){
		navService.updateById(nav);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("article:nav:delete")
    public R delete(@RequestBody Integer[] navIds){
		navService.removeByIds(Arrays.asList(navIds));

        return R.ok();
    }

}
